package com.yanqu.road.server.logic.activity.condition.jieshi;

import com.yanqu.road.entity.activity.ActivityConditionInfo;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.task.TaskModule;
import com.yanqu.road.server.logic.activity.BaseActivityData;
import com.yanqu.road.server.logic.activity.condition.BaseNewRankActivityCondition;

import java.math.BigInteger;

public class JieShiJiaoZiRankCondition extends BaseNewRankActivityCondition {

    public JieShiJiaoZiRankCondition(ActivityInfo activityInfo, ActivityConditionInfo activityConditionInfo, BaseActivityData baseActivityData) {
        super(activityInfo, activityConditionInfo, baseActivityData);
    }

    @Override
    protected void player_BoardLevelHandle(Object object) {
        JieShiJiaoZiRankParam params = (JieShiJiaoZiRankParam) object;
        if (params != null) {
            if (params.getJiaoZi().compareTo(getValue()) > 0 || !params.getNickName().equals(getParam())) {
                setValue(params.getJiaoZi());
                setParam(params.getNickName());
                rankChange();
            }
        }

    }

    @Override
    public void addTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().addListener(eGamePlayerEventType.JieShiJiaoZiRank.getValue(), handle);
    }

    @Override
    public void removeTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().removeListener(eGamePlayerEventType.JieShiJiaoZiRank.getValue(), handle);
    }
}
